package com.hdp.jetpack_mvvm.lifecycle

import android.content.Context
import android.util.Log
import androidx.lifecycle.*

/**
 * 监听生命周期改变
 */
open class LifecycleObserver2 constructor(
    val callBack: (String) -> Unit
) :
    LifecycleEventObserver {

    val tag = "Lifecycle2"

    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    fun myOnResume() {
        callBack.invoke("myResume")
    }

    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
        callBack.invoke("onStateChanged:event:${event.name}")
    }

}